package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.PtfInterfaceGroup;
import com.ruoyi.system.service.IPtfInterfaceGroupService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;

/**
 * 接口组Controller
 * 
 * @author ruoyi
 * @date 2022-11-20
 */
@RestController
@RequestMapping("/interfaceGroup")
public class PtfInterfaceGroupController extends BaseController
{
    @Autowired
    private IPtfInterfaceGroupService ptfInterfaceGroupService;

    /**
     * 查询接口组列表
     */
    @RequiresPermissions("system:interfaceGroup:list")
    @GetMapping("/list")
    public AjaxResult list(PtfInterfaceGroup ptfInterfaceGroup)
    {
        List<PtfInterfaceGroup> list = ptfInterfaceGroupService.selectPtfInterfaceGroupList(ptfInterfaceGroup);
        return AjaxResult.success(list);
    }

    /**
     * 导出接口组列表
     */
    @RequiresPermissions("system:interfaceGroup:export")
    @Log(title = "接口组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PtfInterfaceGroup ptfInterfaceGroup)
    {
        List<PtfInterfaceGroup> list = ptfInterfaceGroupService.selectPtfInterfaceGroupList(ptfInterfaceGroup);
        ExcelUtil<PtfInterfaceGroup> util = new ExcelUtil<PtfInterfaceGroup>(PtfInterfaceGroup.class);
        util.exportExcel(response, list, "接口组数据");
    }

    /**
     * 获取接口组详细信息
     */
    @RequiresPermissions("system:interfaceGroup:query")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return AjaxResult.success(ptfInterfaceGroupService.selectPtfInterfaceGroupByGroupId(groupId));
    }

    /**
     * 新增接口组
     */
    @RequiresPermissions("system:interfaceGroup:add")
    @Log(title = "接口组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtfInterfaceGroup ptfInterfaceGroup)
    {
        return toAjax(ptfInterfaceGroupService.insertPtfInterfaceGroup(ptfInterfaceGroup));
    }

    /**
     * 修改接口组
     */
    @RequiresPermissions("system:interfaceGroup:edit")
    @Log(title = "接口组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtfInterfaceGroup ptfInterfaceGroup)
    {
        return toAjax(ptfInterfaceGroupService.updatePtfInterfaceGroup(ptfInterfaceGroup));
    }

    /**
     * 删除接口组
     */
    @RequiresPermissions("system:interfaceGroup:remove")
    @Log(title = "接口组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds)
    {
        return toAjax(ptfInterfaceGroupService.deletePtfInterfaceGroupByGroupIds(groupIds));
    }
}
